<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">

	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
							
							</li>
							<li>所属广告位：<select name="adsName" id='orgid'>
							  
							</select></li>

							<li>关键字：<input type="text" name="key" />
							</li>

							<li><a class="btn btn-primary btn-rounded btn-sm"
								onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm"
								onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>

			<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()"
					shiro:hasPermission="gxgw_modules:adsList:add"> <i
					class="fa fa-plus"></i> 添加
				</a> <a class="btn btn-primary btn-edit disabled"
					onclick="$.operate.edit()"
					shiro:hasPermission="gxgw_modules:adsList:edit"> <i
					class="fa fa-edit"></i> 修改
				</a> <a class="btn btn-danger btn-del btn-del disabled"
					onclick="$.operate.removeAll()"
					shiro:hasPermission="gxgw_modules:adsList:remove"> <i
					class="fa fa-remove"></i> 删除
				</a> <a class="btn btn-warning" onclick="$.table.exportExcel()"
					shiro:hasPermission="gxgw_modules:adsList:export"> <i
					class="fa fa-download"></i> 导出
				</a>
				
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
	<div th:include="include :: footer"></div>
	<script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('gxgw_modules:adsList:edit')}]];
        var removeFlag = [[${@permission.hasPermi('gxgw_modules:adsList:remove')}]];
        var prefix = ctx + "gxgw_modules/adsList";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "广告管理",
				search: false,
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'adsListId', 
					title : '序号',
					visible: false
				},
				{
					field : 'adsListTitle', 
					title : '广告标题',
					sortable: true
				},
				{
					field : 'adsListImage', 
					title : '广告封面',
					sortable: true,
					formatter: function (value) {
                        switch (value) {
							case '无':
							    return "无"
							default:
                                return '<img width="80px" height="60px"alt="image" src="/profile/adsList/'+value+'"  />';
                        }
						/*var s=[[@{/profile/logo/+value}]];*/
                    }
				},
				{
					field : 'adsListUrl', 
					title : '广告链接',
					sortable: true
				},
				{
					field : 'adsListDetail', 
					title : '详情',
					sortable: true
				},
			
				{
					field : 'adsListState', 
					title : '使用状态',
					sortable: true,
					formatter: function (value) {
						switch (value) {
							case 0:
								return '可用'
							case 1:
								return '停用'
							
						}
					}
					
				},
				{
					field : 'adsListPublic', 
					title : '发布时间',
					sortable: true
				},
				{
					field : 'createBy', 
					title : '创建人',
					sortable: true
				},
				{
					field : 'createTime', 
					title : '创建时间',
					sortable: true
				},
				{
					field : 'updateBy', 
					title : '最后修改人',
					sortable: true
				},
				{
					field : 'updateTime', 
					title : '修改时间',
					sortable: true
				},
				{
					field : 'remark', 
					title : '备注',
					sortable: true
				},
				{
					field : 'adsName', 
					title : '所属广告位',
					
				},
				
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.adsListId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.adsListId + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
            adsName();
            function adsName(){
            	$.ajax({
                    type: "post",
                    url:prefix + "/selectAdsName",
                    dataType: "json",
                    success: function(res){
                        if (null != res) {
                            var html = '  <option value="">所有</option>';
                            Object.keys(res).forEach(function(key){
                                html += '<option th:value="' + res[key].adsId + '" th:text="'+ res[key].adsName+'" class="choice">' + res[key].adsName+ '</option>';
                            });
                            $('#orgid').html(html);
                            //必须加，刷新select
                        }}
                 });
            }
            $('select#orgid').change(function(){
               
            	$.table.search();
                });
        
        });
    </script>
</body>
</html>